﻿Option Strict On

Partial Class Pages_Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        rptNews.DataSource = New NewsDAO().getAllNews()
        rptNews.DataBind()

    End Sub

    'Lägger in ID på vajre "Läs mer" länk och skickar den till rätt sida
    Protected Sub rptNews_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptNews.ItemDataBound
        Dim link As HyperLink
        link = CType(e.Item.FindControl("hplReadMore"), HyperLink)

        Dim NewsDao = New NewsDAO().getAllNews
        Dim news As News
        news = CType(e.Item.DataItem, News)
        Dim id = news.NewsID

        If news.NewsSection = 1 Then
            link.NavigateUrl = "Sparetime.aspx?id=" & id
        ElseIf news.NewsSection = 2 Then
            link.NavigateUrl = "School.aspx?id=" & id
        ElseIf news.NewsSection = 3 Then
            link.NavigateUrl = "Work.aspx?id=" & id
        End If

    End Sub
End Class
